<%- include('header'); %>

<body class="hold-transition login-page">
        <div class="login-box">
          <div class="login-logo">
            <a href="/"><b>Dapps</b>应用商店</a>
          </div>
          <!-- /.login-logo -->
          <div class="card">
            <div class="card-body login-card-body">
              <p class="login-box-msg">登录</p>
        
              <form>
                <div class="input-group mb-3">
                  <input type="text" id="username" class="form-control" placeholder="用户名" value="">
                  <div class="input-group-append">
                    <div class="input-group-text">
                      <span class="fas fa-envelope"></span>
                    </div>
                  </div>
                </div>
                <div class="input-group mb-3">
                  <input type="password" id="pwd" class="form-control" placeholder="密码" value="">
                  <div class="input-group-append">
                    <div class="input-group-text">
                      <span class="fas fa-lock"></span>
                    </div>
                  </div>
                </div>
                <div class="row">
                    <a href="#" id="login" class="btn btn-block btn-primary">
                        登录
                    </a>
                    
                </div>
              </form>
              <!-- <div class="social-auth-links text-center">
                <a href="/html/v1/register" class="text-center">我没有有账号，去注册</a>
              </div> -->

            </div>
            <!-- /.login-card-body -->
          </div>
        </div>
  
<script>
    $(function(){
      $('#login').click(function() {
        var username = $('#username').val();
        var pwd = $('#pwd').val();
        var params = {
          username: username,
          pwd: pwd
        };
        $.post('/api/v1/admin/login',params,function(result){      
          console.log('result:', result);
            if (result.code !== 0) {
                alert(result.msg);
            } else {
                localStorage.setItem('token', result.data.token);   
                localStorage.setItem('username', result.data.user_info.username);
                localStorage.setItem('user_info', JSON.stringify(result.data.user_info));
                var url = "/html/v1/store/quick";
                window.location.href= url;
            }
        });    
      });
    })
</script>
<!-- Bootstrap 4 -->
<script src="/public/plugins/bootstrap/js/bootstrap.bundle.min.js"></script>

</body>
</html>